import requests

# 登录
url = "http://ihrm-test.itheima.net/api/sys/login"
test_data = {"mobile": "13800000002", "password": "123456"}
response = requests.post(url=url, json=test_data)
print(response.json())
token=response.json().get("data")

# 添加
url = "http://ihrm-test.itheima.net/api/sys/user"
tou = {
    "Authorization": token
}
ti ={
    "username":"tom123",
    "mobile":"15655865648",
    "workNumber":"765478"
}
response = requests.post(url=url,headers=tou,json=ti)
print(response.json())
id = response.json().get("data").get("id")
# 查询
url = f"http://ihrm-test.itheima.net/api/sys/user/{id}"

tou = {
    "Authorization":token
}
aa = requests.get(url=url, headers=tou)
print(aa.json())
# 修改
url = f"http://ihrm-test.itheima.net/api/sys/user/{id}"
tou = {
    "Authorization":token
}
ti = {
    "username":"孙军乐"
}
response = requests.put(url=url,headers=tou,json=ti)
print(response.json())
# 删除
url = f"http://ihrm-test.itheima.net/api/sys/user/{id}"

tou = {
    "Authorization":token
}
aa = requests.delete(url=url, headers=tou)
print(aa.json())